<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php
//Tiina Võsumägi phpkursus1109 14.11

$page = $_GET['page'];
class lihtne_kalkulaator 
{
  var $number1;
  var $number2;

  function liida($number1,$number2)
  {
    $vastus =$number1 + $number2;
    echo("$number1 + $number2 = $vastus");
  }

  function lahuta($number1,$number2)
  {
    $vastus =$number1 - $number2;
    echo("$number1 - $number2 = $vastus");
  }

  function korruta($number1,$number2)
  {
    $vastus =$number1 * $number2;
    echo("$number1 x $number2 = $vastus");
  }
  function jaga($number1,$number2)
  {
    $vastus =$number1 / $number2;
    echo("$number1 ÷ $number2 = $vastus");
  }
}
$lihtne_kalkulaator = new lihtne_kalkulaator();
?>

<form name="lihtne_kalkulaator" action="?page=lihtne_kalkulaator" method="POST">
<h2>Lihtne kalkulaator</h2>
<p>Number 1: <td><input type=text name=value1 size=20 value=<?php echo $number1 ?>></td><br />
Number 2: <td><input type=text name=value2 size=20 value=<?php echo $number2 ?>></td><br />
Vali tehe: <input type=radio name=op value="liida">Liida
           <input type=radio name=op value="lahuta">Lahuta 
		   <input type=radio name=op value="korruta">Korruta 
		   <input type=radio name=op value="jaga">Jaga </input></p>
<td colspan=2><left><input type=submit name=nupp value=Arvuta></left></td>
</form>

<?php
if($page == "lihtne_kalkulaator")
{
$number1 = $_POST['value1'];
$number2 = $_POST['value2'];
$op = $_POST['op'];
if($op == "liida")
{
  $lihtne_kalkulaator->liida($number1,$number2);
}
    if($op == "lahuta")
	{
      $lihtne_kalkulaator->lahuta($number1,$number2);
    }
     if($op == "korruta")
	{
      $lihtne_kalkulaator->korruta($number1,$number2);
    }
     if($op == "jaga")
	{
      $lihtne_kalkulaator->jaga($number1,$number2);
    }
}	 
?>